#define __COMP d

#define FUNC(funcname) __COMP##_fnc_##funcname
#define GVAR(varname) __COMP##_##varname
#define QUOTE(qtext) #qtext
#define QGVAR(varname) QUOTE(GVAR(varname))
#define GOVQ(obje,varname) (obje getVariable #varname)
#define GOV(obje,varname) (obje getVariable varname)
#define TRANSLATE(value) value call XfTranslate

#define PARAM(var,param,default) var = default; \
if (count _this > param) then { var = _this select param; };

#define __MPCheck if (X_MP) then { \
	if ((call FUNC(PlayersNumber)) == 0) then { \
		if (!GVAR(all_simulation_stopped)) then { \
			GVAR(all_simulation_stopped) = true; \
			{_x enableSimulation false} forEach allUnits; \
		}; \
	}; \
	waitUntil {sleep (1.012 + random 1);(call FUNC(PlayersNumber)) > 0}; \
	if (GVAR(all_simulation_stopped)) then { \
		{_x enableSimulation true} forEach allUnits; \
		GVAR(all_simulation_stopped) = false; \
	}; \
};

#define __sideStr(side) if (typename side == typename west) then { str(side) } else { toUpper(side) }
#define __sideChar(side) switch (side) do {case "EAST": {"E"};case "WEST": {"W"};case "GUER": {"G"};case "CIV": {"W"}; default{"E"};}
#define __sideSide(side) switch (__sideStr(side)) do {case "EAST": {east};case "WEST": {west};case "GUER": {resistance};case "CIV": {civilian}; default{east};}

#define __isEast (GVAR(own_side) == "EAST")
#define __isWest (GVAR(own_side) == "WEST")

#define __isFriend(side) ((__sideSide(side)) getFriend (__sideSide(GVAR(own_side))) >= 0.6)
#define __isEnemy(side) ((__sideSide(side)) getFriend (__sideSide(GVAR(own_side))) < 0.6)

#define __ccppfln(xfile1) call compile preprocessFileLineNumbers #xfile1
#define __cppfln(xdfunc,xfile2) xdfunc = compile preprocessFileLineNumbers #xfile2

// Get/Set Mission Namespace variables
#define __getMNsVar(mvarname) (missionNamespace getVariable #mvarname)
#define __mNsSetVar missionNamespace setVariable

#define __INC(vari) vari = vari + 1
#define __DEC(vard) vard = vard - 1

#ifdef THIS_FILE
#define _THIS_FILE_ 'THIS_FILE'
#else
#define _THIS_FILE_ __FILE__
#endif

#define __TRACE(method, msg) if (GVAR(global_debug) >= 10) then { diag_log format ["%1 (%2) [%3-%4] %5(): %6", time, diag_tickTime, _THIS_FILE_, __LINE__, #method, msg]; }
#define __TRACE_1(method, msg, param1) if (GVAR(global_debug) >= 10) then { diag_log format ["%1 (%2) [%3-%4] %5(): %6, %7", time, diag_tickTime, _THIS_FILE_, __LINE__, #method, msg, param1]; }
#define __TRACE_2(method, msg, param1, param2) if (GVAR(global_debug) >= 10) then { diag_log format ["%1 (%2) [%3-%4] %5(): %6 %7 %8", time, diag_tickTime, _THIS_FILE_, __LINE__, #method, msg, param1, param2]; }
#define __DEBUG(method, msg) if (GVAR(global_debug) >= 8) then { diag_log format ["%1 (%2) [%3-%4] %5(): %6", time, diag_tickTime, _THIS_FILE_, __LINE__, #method, msg]; }
#define __DEBUG_1(method, msg, param1) if (GVAR(global_debug) >= 8) then { diag_log format ["%1 (%2) [%3-%4] %5(): %6 %7", time, diag_tickTime, _THIS_FILE_, __LINE__, #method, msg, param1]; }
#define __DEBUG_2(method, msg, param1, param2) if (GVAR(global_debug) >= 8) then { diag_log format ["%1 (%2) [%3-%4] %5(): %6 %7 %8", time, diag_tickTime, _THIS_FILE_, __LINE__, #method, msg, param1, param2]; }
#define __INFO(method, msg) if (GVAR(global_debug) >= 6) then { diag_log format ["%1 (%2) [%3-%4] %5(): %6", time, diag_tickTime, _THIS_FILE_, __LINE__, #method, msg]; }
#define __INFO_1(method, msg, param1) if (GVAR(global_debug) >= 6) then { diag_log format ["%1 (%2) [%3-%4] %5(): %6 %7", time, diag_tickTime, _THIS_FILE_, __LINE__, #method, msg, param1]; }
#define __INFO_2(method, msg, param1, param2) if (GVAR(global_debug) >= 6) then { diag_log format ["%1 (%2) [%3-%4] %5(): %6 %7 %8", time, diag_tickTime, _THIS_FILE_, __LINE__, #method, msg, param1, param2]; }
#define __WARNING(method, msg) if (GVAR(global_debug) >= 4) then { diag_log format ["%1 (%2) [%3-%4] %5(): %6", time, diag_tickTime, _THIS_FILE_, __LINE__, #method, msg]; }
#define __WARNING_1(method, msg, param1) if (GVAR(global_debug) >= 4) then { diag_log format ["%1 (%2) [%3-%4] %5(): %6 %7", time, diag_tickTime, _THIS_FILE_, __LINE__, #method, msg, param1]; }
#define __WARNING_2(method, msg, param1, param2) if (GVAR(global_debug) >= 4) then { diag_log format ["%1 (%2) [%3-%4] %5(): %6 %7 %8", time, diag_tickTime, _THIS_FILE_, __LINE__, #method, msg, param1, param2]; }
#define __ERROR(method, msg) if (GVAR(global_debug) >= 2) then { diag_log format ["%1 (%2) [%3-%4] %5(): %6", time, diag_tickTime, _THIS_FILE_, __LINE__, #method, msg]; }
#define __ERROR_1(method, msg, param1) if (GVAR(global_debug) >= 2) then { diag_log format ["%1 (%2) [%3-%4] %5(): %6 %7", time, diag_tickTime, _THIS_FILE_, __LINE__, #method, msg, param1]; }
#define __ERROR_2(method, msg, param1, param2) if (GVAR(global_debug) >= 2) then { diag_log format ["%1 (%2) [%3-%4] %5(): %6 %7 %8", time, diag_tickTime, _THIS_FILE_, __LINE__, #method, msg, param1, param2]; }
